import kyo.CommonMenu;
import kyo.ItemRun;
import kyo.Item;
import kyo.RunState;

public class MenuTest {
    static public void main(String [] args) {
        CommonMenu<String, Object> m = new CommonMenu<String, Object>("===== 一级菜单 ====", "退出程序");

        m.setRun(new ItemRun() {
            public <String, Object> RunState run(
                                Item<String, Object> item) {
                switch (item.getId()) {
                    case 1:
                        System.out.printf("11111111\n");
                        break;
                    case 2:
                        System.out.printf("22222222\n");
                        break;
                    case 3:
                        System.out.printf("44444444\n");
                        break;
                }
                return RunState.RUNNING;
            }
        });

        m.add("三角形!");
        m.add("五角形!");
        m.add("六角形!");

        CommonMenu<String, Object> s = new CommonMenu<String, Object>("---- 二级子菜单 ----", "返回上一级");
        s.setRun(new ItemRun() {
            public <String, Object> RunState run(
                                Item<String, Object> item) {
                switch (item.getId()) {
                    case 1:
                        System.out.printf("Sub 11111111\n");
                        break;
                    case 2:
                        System.out.printf("Sub 22222222\n");
                        break;
                    case 3:
                        System.out.printf("Sub Exit\n");
                        return RunState.QUIT;
                }
                return RunState.RUNNING;
            }
        });

        s.add("直角三角形!");
        s.add("等腰三角形!");
        s.add("等边三角形!");
        m.add(new Item<String, Object>("子菜单三角形", s));

        m.run();
    }
}
